<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="d1">这是div</div>
<input type="text" id="myInput">
<input type="button" value="按钮" onclick="myfn()">
<hr>
<input type="text" id="num_input">
<input type="button"value="计算"onclick="fn2()">
<script>
    function fn2() {
        let i=document.getElementById('num_input')
        let d=document.getElementById('d1')
        // d.innerText=i.value*i.value;
        //i.value*1和parseInt(value)都是将字符串转换成数值的方式
        // d.innerText=i.value*1+i.value*1
        d.innerText=parseInt(i.value)+parseInt(i.value);
    }
</script>
<script>
    function myfn() {
        //    得到文本框和div
        let d = document.getElementById('d1')
        let i = document.getElementById('myInput')
        //取出文本框的值 给到div文本
        // d.innerText = i.value;
        d.innerText=i.value
    }
</script>
</body>
</html>